#ifndef h_threadH
#define h_threadH

#include <pthread.h>

namespace h_base
{

class HThread
{
public :
   explicit HThread();
   virtual ~HThread();
   virtual void Execute() = 0;
   void Start(int StackSize = 0);
   void Wait();
   pthread_t GetTid();

private :
   HThread(const HThread &rhs);
   HThread& operator=(const HThread &rhs);

   static void *ThreadFunc(void*);

   pthread_t FTid;
};

class HMutex
{
public :
   HMutex();
   ~HMutex();
   void Lock();
   void Unlock();
   pthread_mutex_t *GetPthreadMutex()
   {
      return &FMutex;
   }
private :
   pthread_mutex_t FMutex;
};

class HThreadCond
{
public :
   HThreadCond(HMutex *AMutex);
   ~HThreadCond();
   void Wait();
   bool TimedWait(int Millisecond);
   void Signal();
   void Broadcast();
private :
   pthread_cond_t FCond;
   HMutex *FMutex;
};

}; // namespace h_base

#endif
